package com.src.xyzk_personal.config;

import android.content.Context;

import com.src.xyzk_personal.R;

import java.util.ArrayList;

public class EcuModule
{
	String name;
	int Position;
	int result; //0--失败，1--成功
	ArrayList<String> mList;
	private Context mContext;

	public EcuModule()
	{
		name = "";
		Position  = -1;
		result = -1;
		mList = new ArrayList<>();
	}
	public EcuModule(String Pname, Context context)
	{
		name = Pname;
		Position  = -1;
		result = -1;
		mList = new ArrayList<>();
		mContext = context;

	}
	public String getname() {
		return name;
	}
	public void setname(String P) {
		this.name = P;
	}
	public Integer getPosition() {
		return Position;
	}
	public void setPosition(int P) {
		this.Position = P;
	}
	public Integer getresult() {
		return result;
	}
	public void setresult(int P) {
		this.result = P;
	}
	public void addcontext(String Pcontext)
	{
		mList.add(Pcontext);
	}
	public ArrayList<String> getcontext()
	{
		return mList;
	}
	public String toString()
	{
		StringBuilder str = new StringBuilder();
		if(result == 1) //ok
		{
			str = new StringBuilder("★" + name + ":  " + mContext.getResources().getString(R.string.success) + ";");
		}
		else
		{
			str = new StringBuilder("★" + name + ":  " + mContext.getResources().getString(R.string.failure) + ";");
		}
		if(mList != null)
		{
			for(int k = 0; k < mList.size(); k ++)
				if (str.toString().contains(mContext.getResources().getString(R.string.failure))) {
					str.append(mList.get(k)).append(mContext.getResources().getString(R.string.failure)).append(";");
				} else if (str.toString().contains(mContext.getResources().getString(R.string.success))) {
					str.append(mList.get(k)).append(mContext.getResources().getString(R.string.success)).append(";");
				}
		}
		return str.toString();
	}
}